package com.ytc.www.controller;

import com.ytc.www.dto.ResponseBox;
import com.ytc.www.dto.UserDTO;
import com.ytc.www.entity.EducationUser;
import com.ytc.www.openfeignclient.ConsumerUserControllerClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
public class ConsumerUserController {
    @Autowired
    private ConsumerUserControllerClient consumerUserControllerClient;

    @RequestMapping("/api/users/getAll")
    public ResponseBox getAll(HttpServletRequest request, HttpServletResponse response,UserDTO userDTO, int gotoPage) {
        System.out.println("consumer invoked");
        return consumerUserControllerClient.getAll(userDTO,gotoPage);
    }
    @GetMapping(value = "/api/users/{id}")
    public ResponseBox getById(@PathVariable("id") int id){
        return consumerUserControllerClient.getById(id);
    }
    @DeleteMapping(value = "/api/users/{id}")
    public ResponseBox delete(@PathVariable("id") int id) {
        return consumerUserControllerClient.delete(id);
    }
    @PostMapping(value = "/api/users/update")
    public ResponseBox update(HttpServletRequest request, HttpServletResponse response, @RequestBody EducationUser user) {
        return consumerUserControllerClient.update(user);
    }
}
